Clutter has had clutter_backend_get_resolution for a little while.
https://bugzilla.gnome.org/show_bug.cgi?id=672807
"clutter.stagePaintDone");
}
-static void
-update_font_options (GtkSettings *settings,
- ClutterStage *stage)
-{
- StThemeContext *context;
- gint dpi;
-
- g_object_get (settings,
- "gtk-xft-dpi", &dpi,
- NULL);
-
- context = st_theme_context_get_for_stage (stage);
-
- if (dpi != -1)
- /* GTK stores resolution as 1024 * dots/inch */
- st_theme_context_set_resolution (context, dpi / 1024);
- else
- st_theme_context_set_default_resolution (context);
-}
-
-static void
-settings_notify_cb (GtkSettings *settings,
- GParamSpec *pspec,
- gpointer data)
-{
- update_font_options (settings, CLUTTER_STAGE (data));
-}
-
static void
shell_fonts_init (ClutterStage *stage)
{
- GtkSettings *settings;
CoglPangoFontMap *fontmap;
/* Disable text mipmapping; it causes problems on pre-GEM Intel
*/
fontmap = COGL_PANGO_FONT_MAP (clutter_get_font_map ());
cogl_pango_font_map_set_use_mipmapping (fontmap, FALSE);
-
- settings = gtk_settings_get_default ();
- g_object_connect (settings,
- "signal::notify::gtk-xft-dpi",
- G_CALLBACK (settings_notify_cb), stage,
- NULL);
- update_font_options (settings, stage);
}
/* This is an IBus workaround. The flow of events with IBus is that every time
struct _StThemeContext {
GObject parent;
- double resolution;
PangoFontDescription *font;
StThemeNode *root_node;
StTheme *theme;
GObjectClass parent_class;
};
-#define DEFAULT_RESOLUTION 96.
#define DEFAULT_FONT "sans-serif 10"
enum
static void
st_theme_context_init (StThemeContext *context)
{
- context->resolution = DEFAULT_RESOLUTION;
context->font = pango_font_description_from_string (DEFAULT_FONT);
g_signal_connect (st_texture_cache_get_default (),
return context->theme;
}
-/**
- * st_theme_context_set_resolution:
- * @context: a #StThemeContext
- * @resolution: resolution of the context (number of pixels in an "inch")
- *
- * Sets the resolution of the theme context. This is the scale factor
- * used to convert between points and the length units pt, in, and cm.
- * This does not necessarily need to correspond to the actual number
- * resolution of the device. A value of 72. means that points and
- * pixels are identical. The default value is 96.
- */
-void
-st_theme_context_set_resolution (StThemeContext *context,
- double resolution)
-{
- g_return_if_fail (ST_IS_THEME_CONTEXT (context));
-
- if (resolution == context->resolution)
- return;
-
- context->resolution = resolution;
- st_theme_context_changed (context);
-}
-
-/**
- * st_theme_context_set_default_resolution:
- * @context: a #StThemeContext
- *
- * Sets the resolution of the theme context to the default value of 96.
- * See st_theme_context_set_resolution().
- */
-void
-st_theme_context_set_default_resolution (StThemeContext *context)
-{
- g_return_if_fail (ST_IS_THEME_CONTEXT (context));
-
- if (context->resolution == DEFAULT_RESOLUTION)
- return;
-
- context->resolution = DEFAULT_RESOLUTION;
- st_theme_context_changed (context);
-}
-
-/**
- * st_theme_context_get_resolution:
- * @context: a #StThemeContext
- *
- * Gets the current resolution of the theme context.
- * See st_theme_context_set_resolution().
- *
- * Return value: the resolution (in dots-per-"inch")
- */
-double
-st_theme_context_get_resolution (StThemeContext *context)
-{
- g_return_val_if_fail (ST_IS_THEME_CONTEXT (context), DEFAULT_RESOLUTION);
-
- return context->resolution;
-}
-
/**
* st_theme_context_set_font:
* @context: a #StThemeContext
StTheme *theme);
StTheme * st_theme_context_get_theme (StThemeContext *context);
-void st_theme_context_set_resolution (StThemeContext *context,
- gdouble resolution);
-void st_theme_context_set_default_resolution (StThemeContext *context);
-double st_theme_context_get_resolution (StThemeContext *context);
void st_theme_context_set_font (StThemeContext *context,
const PangoFontDescription *font);
const PangoFontDescription *st_theme_context_get_font (StThemeContext *context);
break;
case POINTS:
{
- double resolution = st_theme_context_get_resolution (node->context);
+ double resolution = clutter_backend_get_resolution (clutter_get_default_backend ());
*length = num->val * multiplier * (resolution / 72.);
}
break;
}
else
{
- double resolution = st_theme_context_get_resolution (node->context);
+ double resolution = clutter_backend_get_resolution (clutter_get_default_backend ());
*length = num->val * multiplier * (resolution / 72.) * font_size;
}
}
{
if (term->type == TERM_IDENT)
{
- double resolution = st_theme_context_get_resolution (node->context);
+ double resolution = clutter_backend_get_resolution (clutter_get_default_backend ());
/* We work in integers to avoid double comparisons when converting back
* from a size in pixels to a logical size.
*/
parent_size = pango_font_description_get_size (node->font_desc);
if (!pango_font_description_get_size_is_absolute (node->font_desc))
{
- double resolution = st_theme_context_get_resolution (node->context);
+ double resolution = clutter_backend_get_resolution (clutter_get_default_backend ());
parent_size *= (resolution / 72.);
}
stage = clutter_stage_new ();
context = st_theme_context_get_for_stage (CLUTTER_STAGE (stage));
st_theme_context_set_theme (context, theme);
- st_theme_context_set_resolution (context, 96.);
st_theme_context_set_font (context,
pango_font_description_from_string ("sans-serif 12"));